home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / src / test / ovlsucc.sml < prev    next >
Encoding:
Text File  |  1997-08-18  |  3.1 KB  |  91 lines  |  [TEXT/R*ch]

  1. (* ovlsucc.sml 
  2.    Test of successful overloading resolution as per the New Definition.
  3.  *  PS 1996-04-12, 1997-07-13
  4.  *)
  5.  
  6. type word8 = Word8.word;
  7.  
  8. fun iii1 x y = x + y;
  9. fun iii2 x y = x - y;
  10. fun iii3 x y = x * y;
  11. fun iii4 x y = x div y;
  12. fun iii5 x y = x mod y; 
  13. fun iii6 x y = x < y;
  14. fun iib7 x y = x > y;
  15. fun iib8 x y = x <= y;
  16. fun iib9 x y = x >= y;
  17. fun ii10 x = abs x;
  18. fun ii11 x = ~ x;
  19.  
  20. fun www1 x y = x + y before ignore (y + 0w0);
  21. fun www2 x y = x - y before ignore (y + 0w0);
  22. fun www3 x y = x * y before ignore (y + 0w0);
  23. fun www4 x y = x div y before ignore (y + 0w0);
  24. fun www5 x y = x mod y before ignore (y + 0w0); 
  25. fun www6 x y = x < y before ignore (y + 0w0);
  26. fun wwb7 x y = x > y before ignore (y + 0w0);
  27. fun wwb8 x y = x <= y before ignore (y + 0w0);
  28. fun wwb9 x y = x >= y before ignore (y + 0w0);
  29.  
  30. fun www1 x y = x + y before ignore (y + 0w0 : word8);
  31. fun www2 x y = x - y before ignore (y + 0w0 : word8);
  32. fun www3 x y = x * y before ignore (y + 0w0 : word8);
  33. fun www4 x y = x div y before ignore (y + 0w0 : word8);
  34. fun www5 x y = x mod y before ignore (y + 0w0 : word8); 
  35. fun www6 x y = x < y before ignore (y + 0w0 : word8);
  36. fun wwb7 x y = x > y before ignore (y + 0w0 : word8);
  37. fun wwb8 x y = x <= y before ignore (y + 0w0 : word8);
  38. fun wwb9 x y = x >= y before ignore (y + 0w0 : word8);
  39.  
  40. fun rrr1 x y = x + y before ignore (y + 0.0);
  41. fun rrr2 x y = x - y before ignore (y + 0.0);
  42. fun rrr3 x y = x * y before ignore (y + 0.0);
  43. fun rrb4 x y = x < y before ignore (y + 0.0);
  44. fun rrb5 x y = x > y before ignore (y + 0.0);
  45. fun rrb6 x y = x <= y before ignore (y + 0.0);
  46. fun rrb7 x y = x >= y before ignore (y + 0.0);
  47. fun rr8 x = abs x before ignore (x + 0.0);
  48. fun rr9 x = ~ x before ignore (x + 0.0);
  49.  
  50. fun ssb1 x y = x < y before ignore (y ^ "");
  51. fun ssb2 x y = x > y before ignore (y ^ "");
  52. fun ssb3 x y = x <= y before ignore (y ^ "");
  53. fun ssb4 x y = x >= y before ignore (y ^ "");
  54.  
  55. fun ccb1 x y = x < y before ignore (ord y);
  56. fun ccb2 x y = x > y before ignore (ord y);
  57. fun ccb3 x y = x <= y before ignore (ord y);
  58. fun ccb4 x y = x >= y before ignore (ord y);
  59.  
  60. fun succ1 (x as 0w255) = [x, x, x, 0w0 : word8]
  61.   | succ1 _ = [];
  62. fun succ2 (x as 0w256) = [x, x, x, 0w0]
  63.   | succ2 _ = [];
  64.  
  65. fun less (x, y) = x < y
  66. fun minii(x, y) = if less(x, y) then x else y;
  67.  
  68. fun is12 x = makestring x;
  69. fun ws10 x = makestring x before ignore (x + 0w0); 
  70. fun ws10 x = makestring x before ignore (x + 0w0 : word8); 
  71. fun rs10 x = makestring x before ignore (x + 0.0);
  72. fun ss5 x = makestring x before ignore (x ^ "");
  73. fun cs5 x = makestring x before ignore (ord x);
  74.  
  75. (* Testing optimized equality (int, char, word) *)
  76.  
  77. val eei1 = 11700 = 11700 andalso 11171 <> 11172;
  78. val eew1 = 0wx12345 = 0wx12345 andalso 0wx12345 <> 0wx12354;
  79. val eec1 = #"A" = #"A" andalso #"C" <> #"D";
  80. val eeg1 = 
  81.     "abc" = "abc" andalso "abc" <> "ABC" 
  82.     andalso 117.0 = 117.0 andalso 117.1 <> 117.0
  83.     andalso [1] = [1] andalso [0] <> [1]
  84.     andalso [0w117] = [0w117] andalso [0w118] <> [0w117];
  85.  
  86. let fun loop1 n = if n=0 then 7 else loop1 (n-1) 
  87. in Mosml.time loop1 5000000 end;
  88.  
  89. fun loop2 n = if n=0 then 7 else loop2 (n-1);
  90. Mosml.time loop2 5000000;
  91.